package com.example.demo.generator.scaffold.dto.log;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

/**
 * 查询脚手架生成日志的请求参数。
 */
@Data
public class ScaffoldLogListRequest {

    @Schema(description = "当前页码", example = "1")
    @Min(value = 1, message = "页码必须大于等于 1")
    private Integer current = 1;

    @Schema(description = "每页数量", example = "20")
    @Min(value = 1, message = "每页数量至少为 1")
    @Max(value = 200, message = "每页数量不能超过 200")
    private Integer pageSize = 20;

    @Schema(description = "按模块名称、基础包或目录模糊匹配")
    private String keyword;

    public long currentOrDefault() {
        return current != null && current > 0 ? current : 1;
    }

    public long pageSizeOrDefault() {
        if (pageSize == null) {
            return 20;
        }
        int size = Math.max(1, pageSize);
        return Math.min(size, 200);
    }
}



